
<script type="text/javascript" src="__PUBLIC__/js/plugins/plupload/plupload.full.min.js"></script>
<script type="text/javascript">
    var uploader = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4',
        browse_button: 'logo_upload_btn', // you can pass in id...
        logo_area_tr: document.getElementById('logo_area_tr'), // ... or DOM Element itself
        url: "{:U('Upload/logo')}",
        flash_swf_url: '__PUBLIC__/js/plupload/Moxie.swf',
        silverlight_xap_url: '__PUBLIC__/js/plupload/Moxie.xap',
        filters: {
            max_file_size: '25mb',
            mime_types: [
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false,
        init: {
            FilesAdded: function(up, files) {
                $("#upload_progress").show();
                $("#btn_submit").attr("disabled", "disabled").addClass("disabled").val("正在上传...");
                uploader.start();
            },
            UploadProgress: function(up, file) { //上传中，显示进度条 
                $("#bar").css({
                    "width": file.percent + "%"
                });
                $("#percent_num").text(file.percent + "%");
            },
            FileUploaded: function(up, file, info) {
                var data = JSON.parse(info.response);
                $("#upload_progress").hide();
                $("#upload_rs").html("<img src='"+data.src+"' alt='"+data.name+"'/>").show();
                $("#logo").val(data.src);
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                if (data.error != '') {
                    alert(data.error);
                }

            },
            Error: function(up, err) {

                if (err.code == -601) {
                    alert("请上传jpg,png,gif,jpeg,zip或rar！");
                    $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                }
            }
        }
    });
    uploader.init();
</script>

